﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ScrumTime.Models;

namespace ScrumTime.ViewModels
{
    public class UserCollectionViewModel 
    {

        static IMembershipService membershipService;

        public List<UserViewModel> UserViewModels { get; set; }

        public UserCollectionViewModel()
        {
            
        }

        private void add(UserViewModel userView) {
            this.UserViewModels.Add(userView);
        }

        public static void checkMembershipService() {
            if (membershipService == null)
            {
                membershipService = new AccountMembershipService();
            }
            
        }



        public static UserCollectionViewModel BuildByNameAlphabetical()
        {
            ScrumTimeEntities scrumTimeEntities = new ScrumTimeEntities();
            UserCollectionViewModel userCollectionViewModel = new UserCollectionViewModel();

            

            foreach (System.Web.Security.MembershipUser m_user in membershipService.GetAllUsers() ) {
                UserViewModel userViewModel = new UserViewModel();

                userCollectionViewModel.add(userViewModel);
            }

            

            //{
            //    ProductViewModels = new List<ProductViewModel>()
            //};

            //var results = from p in scrumTimeEntities.Products
            //              orderby p.Name ascending
            //              select p;
            //foreach (Product product in results)
            //{
            //    ProductViewModel productViewModel = new ProductViewModel()
            //    {
            //        IsCurrent = (product.ProductId == currentProductId) ? true : false,
            //        ProductModel = product
            //    };
            //    productCollectionViewModel.ProductViewModels.Add(productViewModel);
            //}
            
            return userCollectionViewModel;
        }
    }
}